<?php
session_start();
class Pager
{
	var $mau = "#000000";
	function findStart($limit,$count)
	{
		if ((!isset($_SESSION['page'])) || ($_SESSION['page'] == "1") || ((($_SESSION['page']-1)*$limit) >= $count))
		{
			$start = 0;
			$_SESSION['page'] = 1;
		}
		else
		{
			$start = ($_SESSION['page']-1) * $limit;
		}
		
		return $start;
	}
	function findPages($count, $limit)
	{
		$pages = (($count % $limit) == 0) ? $count / $limit : floor($count / $limit) + 1;
		return $pages;
	}
	function pageList($curpage, $pages)
	{
		$page_list = "<font color = '{$this->mau}'>"._PAGE."&nbsp;&nbsp;</font>";
	
		if (($curpage != 1) && ($curpage))
		{
			$page_list .= " <a class=\"separate-page\" href=\"#\" onclick=\"document.adminForm.page.value='1';submitbutton('sm_page');\" title=\""._PAGE_FIRST."\"><img src='images/leftlefticon.gif' class='img-to-button' /></a> ";
		}
	
		if (($curpage-1) > 0)
		{
			$page_list .= "<a class=\"separate-page\" href=\"#\" onclick=\"document.adminForm.page.value='".($curpage-1)."';submitbutton('sm_page');\" title=\""._PAGE_BACK."\"><img src='images/lefticon.gif' class='img-to-button' /></a> ";
		}
	
		for ($i=1; $i<=$pages; $i++)
		{
			if ($i == $curpage)
			{
				$page_list .= "<font color='{$this->mau}'>[".$i."]</font>";
			}
			else
			{
				$page_list .= "<a class=\"separate-page\" href=\"#\" onclick=\"document.adminForm.page.value='".$i."';submitbutton('sm_page');\" title=\""._PAGE." ".$i."\">".$i."</a>";
			}
			$page_list .= " ";
		}

		if (($curpage+1) <= $pages)
		{
			$page_list .= "<a class=\"separate-page\" onclick=\"document.adminForm.page.value='".($curpage+1)."';submitbutton('sm_page');\" title=\""._PAGE_NEXT."\"><img src='images/righticon.gif' class='img-to-button' /></a> ";
		}
		
		if (($curpage != $pages) && ($pages != 0))
		{
			$page_list .= "<a class=\"separate-page\" onclick=\"document.adminForm.page.value='".$pages."';submitbutton('sm_page');\" title=\""._PAGE_END."\"><img src='images/rightrighticon.gif' class='img-to-button' /></a> ";
		}
		$page_list .= "</td>\n";

	return $page_list;
	}
	
	function nextPrev($curpage, $pages)
	{
		$currentGETLIST= Pager::getCurrentGETLIST();
			
		$next_prev = "";
		
		if (($curpage-1) <= 0)
		{
			$next_prev .= "Back";
		}
		else
		{
			$next_prev .= "<a class=\"separate-page\" onclick=\"document.adminForm.page.value='".($curpage-1)."';submitbutton('sm_page');\" >"._PAGE_BACK."</a>";
		}
		$next_prev .= " | ";
		
		if (($curpage+1) > $pages)
		{
			$next_prev .= "Next";
		}
		else
		{
			$next_prev .= "<a class=\"separate-page\" onclick=\"document.adminForm.page.value='".($curpage+1)."';submitbutton('sm_page');\" >"._PAGE_NEXT."</a>";
		}
		return $next_prev;
	}
}
?>
